Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consistent quoting of import Base.:operator and warnings thereof #33158

Merged
merged 7 commits into from
Sep 11, 2019

Conversation

stevengj
Copy link
Member

@stevengj stevengj commented Sep 4, 2019

TLDR: This PR allows quoting in import statements, e.g. import Base.:+, similar to other Julia contexts, and uses quoting for MethodError warnings about shadowed operators.

As was noted recently on discourse, the MethodError printing currently shows a potentially confusing suggestion when a function shadows a Base function if it is an operator, and in general the quoting of symbols (e.g. Base.+ vs. Base.:+) was a bit inconsistent.

For example, if you accidentally shadow +, it prints You may have intended to import Base.+, which may be confusing because if you try to define the function as Base.+ Julia will give an error. This PR changes the error message to quote operators.

Unfortunately, while function Base.:+(...) works, import Base.:+ gave a syntax error, which seems a little inconsistent. So this PR also updates the parser to allow quoted symbols in import statements. Backwards compatible since it was a syntax error previously.

@stevengj stevengj added error handling Handling of exceptions by Julia or the user parser Language parsing and surface syntax labels Sep 4, 2019
src/ast.scm Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error handling Handling of exceptions by Julia or the user parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants